Migrate to official antlr4 package#177211
Conversation
23a5405 to
79258d0
Compare
There was a problem hiding this comment.
This is the antlr4 javascript runtime and should not be confused with the cli that's a java binary used to generate the lexer and parser for defined languages.
26da451 to
16a6499
Compare
|
/ci |
|
Pinging @elastic/appex-sharedux (Team:SharedUX) |
|
@elasticmachine merge upstream |
dej611
left a comment
There was a problem hiding this comment.
Tested with ES|QL and works ok 👍
There was a problem hiding this comment.
This is handled now together with the rest of the validation task.
d9b5c5c to
aa65424
Compare
aa65424 to
7aababd
Compare
💚 Build Succeeded
Metrics [docs]Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @eokoneyo |
vadimkibana
left a comment
There was a problem hiding this comment.
Code changes LGTM, didn't run locally.
| // @ts-expect-error the addParseListener API does exist and is documented here | ||
| // https://github.com/antlr/antlr4/blob/dev/doc/listeners.md | ||
| parser.addParseListener(parseListener); |
There was a problem hiding this comment.
Maybe better to cast to any instead of @ts-expect-error.
There was a problem hiding this comment.
Using @ts-expect-error is actually a better choice for this scenario, in the event that this method becomes present in the type declaration we'd get an error to remove this, unlike with any.
## Summary Up till now, we had to define our own lexer rules for our client-side ES|QL validation. This was because we were using an unofficial ANTLR package (before the official ANTLR had typescript support). Now that we are using the official ANTLR library (as of #177211), we no longer have to encode case insensitivity into the lexer rules themselves because the [`caseInsensitive` option](antlr/antlr4#3399) is now available to us. This means we can adopt the very [same definitions](https://github.com/elastic/elasticsearch/blob/343b1ae1ba74fbf2e75c29adddb2790312dd680b/x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4) that Elasticsearch uses as long as we set `caseInsensitive` (Elasticsearch handles case insensitivity at runtime). ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Summary
This PR migrates kibana away from using the antlr4ts to the official antlr package, so the grammar used in Kibana (for example with ES|QL) is on par with ES.